/*
 * Copyright 2021 DataCanvas
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.dingodb.store.proxy.service;

import com.google.auto.service.AutoService;
import io.dingodb.common.util.Pair;
import io.dingodb.store.proxy.common.Gc;
import io.dingodb.transaction.api.GcObj;
import io.dingodb.transaction.api.GcServiceProvider;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
public class GcService implements io.dingodb.transaction.api.GcService {
    @AutoService(GcServiceProvider.class)
    public static final class GcForServiceProvider implements GcServiceProvider {

        @Override
        public GcService get() {
            return INSTANCE;
        }

    }
    public static final GcService INSTANCE = new GcService();


    @Override
    public void safePointUpdate() {
        Gc.safePointUpdate();
    }

    @Override
    public Pair<String, Long> startSafePointUpdate() {
        return Gc.safePointUpdate();
    }

    @Override
    public GcObj startBackUpSafeByPoint(long point, long latestTso) {
        return Gc.startBackUpSafeByPoint(point, latestTso);
    }

    public List<GcObj> startTenantsBackUpSafeByPoint(long point, long latestTso) {
        return Gc.startTenantsBackUpSafeByPoint(point, latestTso);
    }

    @Override
    public void gcDeleteRegion() {
        Gc.gcDeleteRegion();
    }

}
